package com.youku.plugins.endcardV4New.view
{
   import flash.display.Sprite;
   import com.youku.interfaces.IEndCardV4New;
   import com.youku.plugins.PluginEventDispather;
   import flash.display.Shape;
   import com.youku.plugins.endcardV4New.model.data.PlayerSizeData;
   import com.youku.utils.DrawUtil;
   import com.youku.plugins.endcardV4New.EndCardEvent;
   import flash.events.Event;
   
   public class ShareBackground extends Sprite implements IEndCardV4New
   {
      
      public function ShareBackground() {
         super();
      }
      
      private var _eventManager:PluginEventDispather;
      
      private var _background:Shape;
      
      public function init(param1:Object = null, param2:PluginEventDispather = null, param3:PlayerSizeData = null) : void {
         this._eventManager = param2;
         this._background = DrawUtil.Rectangle(0,0,param3.width,param3.height,0,0.8,null,0);
         addChild(this._background);
         this.visible = false;
         this.changeSize(param3);
         this.addEvent();
      }
      
      private function addEvent() : void {
         this._eventManager.addEventListener(EndCardEvent.ENDCARD_SHARE_BACKGROUND_SHOW,this.onEndCardEvent);
         this._eventManager.addEventListener(EndCardEvent.ENDCARD_SHARE_BACKGROUND_HIDE,this.onEndCardEvent);
      }
      
      private function onEndCardEvent(param1:Event) : void {
         switch(param1.type)
         {
            case EndCardEvent.ENDCARD_SHARE_BACKGROUND_SHOW:
               this.visible = true;
               break;
            case EndCardEvent.ENDCARD_SHARE_BACKGROUND_HIDE:
               this.visible = false;
               break;
         }
      }
      
      private function removeEvent() : void {
         this._eventManager.removeEventListener(EndCardEvent.ENDCARD_SHARE_BACKGROUND_SHOW,this.onEndCardEvent);
         this._eventManager.removeEventListener(EndCardEvent.ENDCARD_SHARE_BACKGROUND_HIDE,this.onEndCardEvent);
      }
      
      public function changeSize(param1:PlayerSizeData = null) : void {
         this._background.width = param1.width;
         this._background.height = param1.height;
      }
      
      public function uninstall() : void {
         this.removeEvent();
         if(contains(this._background))
         {
            removeChild(this._background);
         }
      }
   }
}
